<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>upload模块快速使用</title>
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <script src="/static/js/jquery.min.js"></script>
  <script src="/static/layui/layui.js"></script>

<script>
  layui.use(['layer', 'form', 'upload', 'element'], function(){
      var layer = layui.layer;
      var upload = layui.upload;
      var element = layui.element;

      //执行实例
      var uploadInst = upload.render({
          elem: '#test1' //绑定元素
          ,url: '/layuiFileUpload' //上传接口
          ,done: function(res){ //上传完毕回调
              layer.msg("上传完毕");
              console.log(res.data.src);
              //
              $("img").attr("src", res.data.src);
          }
      });
  });
</script>

</head>

<body>

<img src="/static/img/default.png" width="100px" height="100px"/>

<br/> <br/> <br/>

<button id="test1" type="button" class="layui-btn">
 <i class="layui-icon">&#xe67c;</i>上传图片
</button>

</body>

</html>
